package cn.ivbao.project.xtable;

import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import net.sf.json.JSONArray;
import cn.ivbao.actions.BaseAction;
import com.opensymphony.xwork2.Action;
public class XtableAction extends BaseAction {

private static final Log log = LogFactory.getLog(XtableAction.class);

private Xtable xtable = new Xtable();

public Xtable getXtable() {
	return xtable;
}
public void setXtable(Xtable xtable) {
	this.xtable = xtable;
}
public String select() {
	cn.ivbao.project.xtable.XtableDao td = (cn.ivbao.project.xtable.XtableDao) this.getBean("xtableDao");
	List lt = td.select(xtable);
	for(int i=0;i<lt.size();i++){
		xtable = (Xtable)lt.get(i);
	}
	JSONArray json = JSONArray.fromObject(lt);//List生成JSON对象
	toInStream(json.toString());//将生成的JSON对象转成InputStream
	log.debug(json.toString());
	return Action.SUCCESS;
}
public String add() {
	cn.ivbao.project.xtable.XtableDao td = (cn.ivbao.project.xtable.XtableDao) this.getBean("xtableDao");
	Object lt = td.add(xtable);
	JSONArray json = JSONArray.fromObject(lt);//List生成JSON对象
	toInStream(json.toString());//将生成的JSON对象转成InputStream
	log.debug(json.toString());
	return Action.SUCCESS;
}

}